<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        
        <title><?php echo config_item('site_title'); ?> - View Post</title>
		
		<script src="<?php echo base_url(); ?>application/assets/js/jquery.js"></script>
		<script src="<?php echo base_url(); ?>application/assets/js/jquery-1.6.4.min.js"></script>	
		<script src="<?php echo base_url(); ?>application/jquery/jquery-ui-1.8.13.custom.min.js"></script>
		<script src="<?php echo base_url(); ?>application/assets/js/bootstrap-dropdown.js"></script>
		<link href="<?php echo base_url(); ?>application/jquery/smoothness/jquery-ui-1.8.18.custom.css" rel="stylesheet">
		
		<link href="<?php echo base_url(); ?>application/assets/css/bootstrap.css" rel="stylesheet">
        <style type="text/css">
            body {
				padding-top: 80px;
				padding-bottom: 60px;
				background-color: #f5f5f5;
			  }
			  			  
			  #footer {
			   position:fixed;
			   left:0px;
			   bottom:-20px;
			   height:30px;
			   width:100%;
			}
			li {
				line-height: 15px;
			}
			.textbox {
				box-shadow:1px 1px 8px 1px #B8B8B8;
				padding:10pt;
				margin-top:10pt;
				margin-bottom:10pt;
				min-height:200pt;
			}
			#addlinfo div {
				padding-top: 8pt;
			}

			/* Styles for custom vertical scrollbar */
			::-webkit-scrollbar {
			    width: 10px;
			}
			::-webkit-scrollbar-track {
			    background: #FFF;
			    -webkit-box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
			}
			::-webkit-scrollbar-thumb {
			    background: #CCC;
			    -webkit-box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2);
			}
			::-webkit-scrollbar-thumb:hover {
			    background: #AAA;
			}
			::-webkit-scrollbar-thumb:active {
			    background: #888;
			    -webkit-box-shadow: inset 1px 1px 2px rgba(0,0,0,0.3);
			}
        </style>
        <link href="<?php echo base_url(); ?>application/assets/css/bootstrap-responsive.css" rel="stylesheet">

        <script type="text/javascript">
			$(document).ready(function() {
				//alert('refreshed');
				getCategories();
            });
			
			function getCategories() {
				var baseurl = $("#baseurl").val();

				$.ajax({         
					url: baseurl  + "Categories/getCategories", 
					type: "POST",
					dataType: "json",					        
					success: function(data) { 
						//alert('received data' + data[0].text);
						if(data.length > 0) {
							$("#category").append("<option></option>");
							for(i = 0; i < data.length; i++) {
								$("#category").append("<option>" + data[i].text	+ "</option>");
							}
						} else {
							$("#category").append("<option>...</option>");
						}
					},
					error:function (xhr, ajaxOptions, thrownError){
						alert('Error while getting categories !');
					}
				});
			}

			function save() {
				if($("#articlecontents").val() == '') {
					$("#error").show(300);
				} else {
					$("#form1").submit();
				}
			}
        </script>
	</head>
	<body>
		<?php
			$sessiondata = $this->session->userdata('username');
			if((isset($sessiondata)) && ($sessiondata != '')&&(isset($article)))  {
			echo getTopNav();
			$data = $article;
		?>
		
		<div class="container">
                <div class="row-fluid">                        
					<div class="span9" id="articlecontents">
						<a href="<?php echo base_url(); ?>Articles/editArticle?id=<?php echo $article[0]->id; ?>" class="btn btn-success">Edit</a>
			        	<a href="<?php echo base_url(); ?>Home" class="btn btn-secondary">Cancel</a>

						<div class="textbox well">
							<?php			        			
			        			foreach($article as $item) {
			        				echo $item->article;
			        			}			        			
			        		?>
		        		</div>

		        		<a href="<?php echo base_url(); ?>Articles/editArticle?id=<?php echo $article[0]->id; ?>" class="btn btn-success">Edit</a>
			        	<a href="<?php echo base_url(); ?>Home" class="btn btn-secondary">Cancel</a>
			        </div>

			        <div class="span3">
				    	
				    	<div id="addlinfo" class="textbox muted well" style="margin-top:30pt">
				    		<?php 
			        			foreach($article as $item) {
			        				echo '<div><strong>Posted By:</div><div></strong> ' . $item->uname . '</div>';
			        				echo '<div><strong>Posted on:</div><div></strong> ' . $item->createdon . '</div>';
									echo '<div><strong>Modified on:</div><div></strong> ' . $item->lastmodifiedon . '</div>';
			        				echo '<div><strong>Viewed:</strong> ' . $item->cnt_view . ' times</div>';
						    		echo '<div><strong>Likes:</strong> ' . $item->cnt_likes . '</div>';
						    		echo '<div><strong>Character Count:</strong> ~ ' . strlen($item->article) . '</div>';
			        			}
			        		?>


				    	</div>
				    </div>
                </div><!--/row-->

                <div class="row-fluid">
                	<div class="span9">
	                	<div style="margin-top:10pt;">
					    	<h3 style="color:#707070">Leave a Reply</h3>
					    	<div><textarea class="span12" id="txtcomments" name="txtcomments"
					        placeholder="Enter your comment here" rows="3" style="resize:none"></textarea></div>
					        <div>
					        	<span><input type="checkbox" /> Notify me of follow-up comments</span>
					        	<span class="pull-right"><button class="btn btn-secondary">Post Comment</button></span>
					        </div>
					    </div>
					</div>
                </div>

                <!-- Include footer -->
                <?php include 'footer.php' ?>
            </div>
			
			<!-- Hidden variables -->
			<input type="hidden" id="baseurl" name="baseurl" value="<?php echo base_url(); ?>">
	
	<?php
		} else {
			redirect('Login');
		}
	?>
	</body>
	
	<!-- Placed at the end of the document so the pages load faster -->
    
			
</html>